//
//  YKClientDataManageHeaderView.m
//  YunKang
//
//  Created by leoking870 on 2017/11/30.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKClientDataManageHeaderView.h"

@interface YKClientDataManageHeaderView ()
@property (weak, nonatomic) IBOutlet UILabel *tuoguanUserLabel;
@property (weak, nonatomic) IBOutlet UILabel *linggongUserLabel;
@property (weak, nonatomic) IBOutlet UILabel *caijiUserLabel;
@property (weak, nonatomic) IBOutlet UILabel *peisongUserLabel;
@property (weak, nonatomic) IBOutlet UILabel *clientSumLabel;
@property (weak, nonatomic) IBOutlet UILabel *monthLabel;

@property(nonatomic, strong) NSArray *labels;
@end

@implementation YKClientDataManageHeaderView

- (void)awakeFromNib {
    [super awakeFromNib];
    self.tuoguanUserLabel.text = @"";
    self.linggongUserLabel.text = @"";
    self.caijiUserLabel.text = @"";
    self.peisongUserLabel.text = @"";
    self.clientSumLabel.text = @"";
    self.monthLabel.text = @"";
    self.clientSumLabel.textColor = [UIColor tf_colorWithHexString:@"#188AFB"];

    self.labels = @[self.clientSumLabel, self.monthLabel, self.tuoguanUserLabel, self.linggongUserLabel, self.caijiUserLabel, self.peisongUserLabel];

    for (UIView *label in self.labels) {
        label.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onLabelTapped:)];
        [label addGestureRecognizer:tap];
    }
}

- (void)onLabelTapped:(UITapGestureRecognizer *)tapGestureRecognizer{
    for (UILabel *label in self.labels) {
        label.textColor = [UIColor blackColor];
    }
    ((UILabel *)tapGestureRecognizer.view).textColor = [UIColor tf_colorWithHexString:@"#188AFB"];
    if (self.tapAction) {
        if (tapGestureRecognizer.view == self.tuoguanUserLabel) {
            self.tapAction(@"CT201708231454001");
        }
        if (tapGestureRecognizer.view == self.caijiUserLabel) {
            self.tapAction(@"CT201708231454002");
        }
        if (tapGestureRecognizer.view == self.linggongUserLabel) {
            self.tapAction(@"CT201708231454003");
        }
        if (tapGestureRecognizer.view == self.peisongUserLabel) {
            self.tapAction(@"CT201708231454004");
        }
        if(tapGestureRecognizer.view == self.clientSumLabel){
            self.tapAction(@"");
        }
        if (tapGestureRecognizer.view == self.monthLabel) {
            self.tapAction(@"CT201708231454000");
        }
    }
}


- (void)setData:(NSDictionary *)data {
    _data  =data;
    self.tuoguanUserLabel.text = [NSString stringWithFormat:@"托管客户: %@",data[@"TGKH"]];
    self.linggongUserLabel.text = [NSString stringWithFormat:@"零供客户: %@",data[@"LGKH"]];
    self.caijiUserLabel.text = [NSString stringWithFormat:@"集采客户: %@",data[@"JCKH"]];
    self.peisongUserLabel.text = [NSString stringWithFormat:@"配送客户: %@",data[@"PSKH"]];
}

- (void)setData2:(NSDictionary *)data2 {
    _data2 = data2;
    self.clientSumLabel.text = [NSString stringWithFormat:@"客户总数: %@",data2[@"CUSTOMERNUM"]?:@"0"];
    self.monthLabel.text = [NSString stringWithFormat:@"本月开发: %@",data2[@"MONTHCUSTOMERNUM"]?:@"0"];
}

@end
